<template>
	<view class="box fu" :style="{height:screenHeight+'px'}">
		<view class="zz">
			<view class="xx">
				<span>原始密码</span>
				<input type="text" placeholder="请输入原始密码" placeholder-class="liebinu" v-model="data.oldPassword" />
			</view>
			<view class="xx">
				<span>新密码</span>
				<input type="text" placeholder="请输入新密码" placeholder-class="liebinu" v-model="data.newPassword" />
			</view>
			<view class="xx" style="border: none;">
				<span>确认密码</span>
				<input type="text" placeholder="请再次输入新密码" placeholder-class="liebinu" v-model="data.confirmPassword" />
			</view>
		</view>
		<button class="dibu cc" @click="submit()">保存</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				screenHeight: "",
				data: {
					oldPassword: '',
					newPassword: '',
					confirmPassword: ''
				}
			}
		},
		onLoad() {
			this.screenHeight = uni.getSystemInfoSync().windowHeight;
		},
		methods: {
			submit() {
				if(this.data.newPassword == this.data.confirmPassword){
					
					uni.request({
						// url: `https://wine.heiwangke.net/wine-hjd-bj-api/system/user/profile/updatePwd?oldPassword=${this.data.oldPassword}&newPassword=${this.data.newPassword}`,
						url: `https://wine.pinjiuhejidao.com/wine-hjd-bj-api/system/user/profile/updatePwd?oldPassword=${this.data.oldPassword}&newPassword=${this.data.newPassword}`,
						method: 'PUT',
						header: {
							'Authorization': 'Bearer ' + uni.getStorageSync('token'),
						},
						success: (res) => {
							if (res.data.code == 200) {
								uni.showToast({
									title: '修改成功重新登陆',
									duration: 2000,
									mask: false,
									icon: "none"
								})
								setTimeout(() => {
									uni.reLaunch({
										url: '/pages/tab/login'
									})
								}, 1500)
							} else {
								uni.showToast({
									title: res.data.msg,
									duration: 2000,
									mask: false,
									icon: "none"
								})
							}
					
						},
						fail: (err) => {
							uni.showToast({
								title: err.data.msg,
								duration: 2000,
								mask: false,
								icon: "none"
							})
						},
					
					})
					
				}else{
					uni.showToast({
						title:'两次密码值不一样',
						duration: 2000,
						mask: false,
						icon: "none"
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.dibu {
		position: absolute;
		bottom: 50rpx;
	}

	.fu {
		position: relative;
	}

	.liebinu {
		font-size: 26rpx;
	}

	.cc {
		width: 677rpx;
		height: 80rpx;
		background: linear-gradient(84deg, #24180D 0%, #594629 100%);
		border-radius: 40rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 28rpx;
		color: #FFFFFF;
		line-height: 33rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.zz {
		width: 650rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 20rpx;



		.xx {
			display: flex;
			align-items: center;
			border-bottom: 1px solid #EEEEEE;
			height: 100rpx;

			span {
				width: 150rpx;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 30rpx;
				color: #0A0A0A;
				line-height: 36rpx;
			}
		}
	}
</style>